using Digitalmes.Domain.Entities.Mes.Processes;

namespace Digitalmes.Application.Mes.Processes.StepTasks.Commands;

/// <summary>
/// 删除工步命令。
/// </summary>
public sealed record DeleteStepTaskCommand(long StepTaskId) : IRequest<IResult<bool>>;

internal sealed class DeleteStepTaskCommandHandler(IRepository<ProcStepTask> repo) : IRequestHandler<DeleteStepTaskCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteStepTaskCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.StepTaskId, cancellationToken);
        return Result.From(ok);
    }
}
